//
//  L_FirstRecommendCollectionViewCell.m
//  音悦咖
//
//  Created by dllo on 15/7/14.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "L_FirstRecommendCollectionViewCell.h"

@implementation L_FirstRecommendCollectionViewCell

- (void)dealloc
{
    [_backGroundImage release];
    [_recommendModel release];
    [_mainTitle release];
    [_subTitle release];
    [_mainImage release];
    [_subImage release];
    [super dealloc];
}

// 初始化方法
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 创建底色image
        self.backGroundImage = [[UIImageView alloc] init];
        self.backGroundImage.backgroundColor = [UIColor clearColor];
        [self addSubview:self.backGroundImage];
        [_backGroundImage release];
        
        // 创建ImageView
        self.mainImage = [[UIImageView alloc] init];
        self.mainImage.backgroundColor = [UIColor redColor];
        
        [self addSubview:self.mainImage];
        [_mainImage release];
        
        // 创建mainLabel
        self.mainTitle = [[UILabel alloc] init];
//        self.mainTitle.backgroundColor = [UIColor redColor];
        self.mainTitle.font = [UIFont systemFontOfSize:20];
        self.mainTitle.textColor = [UIColor whiteColor];
        self.mainTitle.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.mainTitle];
        [_mainTitle release];
        
        // 创建subLabel
        self.subTitle = [[UILabel alloc] init];
        self.subTitle.backgroundColor = [UIColor redColor];
        self.subTitle.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.subTitle];
        [_subTitle release];
        
        // 创建subImage
        self.subImage = [[UIImageView alloc] init];
        self.subImage.image = [UIImage imageNamed:@"xuanzhong.png"];
        [self addSubview:self.subImage];
        [_subImage release];
    
        
    }
    return self;
}

// 布局
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.backGroundImage.frame = self.bounds;
    self.mainImage.frame = CGRectMake(5, 5, layoutAttributes.frame.size.width / 4 - 10, layoutAttributes.frame.size.height - 10);
    self.mainTitle.frame = CGRectMake(self.mainImage.frame.size.width + 25, layoutAttributes.frame.size.height / 6, (layoutAttributes.frame.size.width - self.mainImage.frame.size.width) / 3 * 2, layoutAttributes.frame.size.height / 3);
//    self.subTitle.frame = CGRectMake(self.mainImage.frame.size.width + 15, layoutAttributes.frame.size.height / 2 + 5, (layoutAttributes.frame.size.width - self.mainImage.frame.size.width) / 3 * 2, layoutAttributes.frame.size.height / 3);
    self.subImage.frame = CGRectMake(layoutAttributes.frame.size.width - layoutAttributes.frame.size.height / 3 - 5, layoutAttributes.frame.size.height / 3, layoutAttributes.frame.size.height / 4, layoutAttributes.frame.size.height / 4);
    [self.layer setCornerRadius:5];
    self.clipsToBounds = YES;

    
}

#pragma mark - 赋值
- (void)setRecommendModel:(L_PosterModel *)recommendModel
{
    if (_recommendModel != recommendModel) {
        [_recommendModel release];
        _recommendModel = [recommendModel retain];
    }
    // 赋值
    [self.mainImage setImageWithURL:[NSURL URLWithString:recommendModel.pic_url] placeholderImage:[UIImage imageNamed:@"place.jpg"]];
    self.mainTitle.text = recommendModel.name;
    //self.subTitle.text = recommendModel.desc;
    self.subImage.image = [UIImage imageNamed:@"xuanzhong"];

    
    
}




@end
